<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="../../../common/include.jsp"%>
<html>
<head>
<jsp:include page="../../../common/head.jsp"></jsp:include>
<title>选择用户</title>
<script language="javascript">
	var strs="";
	function addStr(str){
		for(var i=0;i<str.length;i++){
			if(strs.indexOf(str[i])==-1){
				strs+=str[i]+";";
			}
		}
	}
	function delStr(s){
		var str = strs.split(";");
		strs="";
		for(var i=0;i<str.length;i++){
			if(str[i].indexOf(s)==-1){
				if(str[i]!=";" && str[i]!=""){
					strs+=str[i]+";";
				}
			}
		}
		
	}
	//选择用户
	function add(str){
		var s="";
		addStr(str.split(";"));

		if(strs.length>1)
		s=strs.substring(0,strs.length-1)
		var users = s.split(";");
		var users_len = users.length;
		if(users_len>0){
			for(i=0;i<users.length;i++){
				//-----为select框赋值-----
				var userid = users[i].split(",")[0];
				var username = users[i].split(",")[1];
				document.getElementById("selectUserRight").options[i] = new Option(username,users[i]); 
			}
		}
	}
	//移除指定的用户
	function del(){
		var objSelect = document.getElementById("selectUserRight"); 
		var opt=document.getElementById("selectUserRight").options;
		len=opt.length;
		for(i=len-1;i>-1;i--){
			if(opt[i].selected){
			delStr(opt[i].value);
				objSelect.options[objSelect.selectedIndex] = null; 
			}
		}
		
	}
	//移除指定的用户勾选用户
	function delck(str){
		var objSelect = document.getElementById("selectUserRight"); 
		var opt=document.getElementById("selectUserRight").options;
		len=opt.length;
		for(i=len-1;i>-1;i--){
			if(opt[i].value == str){
			opt[i].selected=true;
			delStr(opt[i].value);
				objSelect.options[objSelect.selectedIndex] = null; 
			}
		}
		
	}
	//移除全部用户
	function delAll(){
		var objSelect = document.getElementById("selectUserRight"); 
		var opt=document.getElementById("selectUserRight").options;
		len=opt.length;
		for(i=len-1;i>-1;i--){
			objSelect.options[i] = null; 
		}
		strs="";
	}
	//全选右侧select
	function selectAll()
	{
		var o = document.getElementById("selectUserRight");
		for(i=0;i<o.options.length;i++){
			o.options[i].selected=true;
		}
	}
	
	

</script>
</head>
<body>
<div id="body_div">
	<w:ShowTitle name="选择用户">
	</w:ShowTitle>
	
	<div id="body_content">
	<form action="" name="from1" method="post">
	<table width="100%" border="0">
	    <tr>
	      <td width="150" valign="top" align="left">
			<select name="selectUserRight" id="selectUserRight" multiple size="9" class="mulitSelectLength"></select>
	      </td>
	      <td>
	        <img src="../../../images/main/delete.gif"  onClick="del()" title="移除" style="cursor:pointer"/>
	      	<br><br><br>
			<img src="../../../images/main/deleteAll.gif"  onClick="delAll()" title="全部移除" style="cursor:pointer"/>
	
	      </td>
	    </tr>
	</table>
	</form>
	</div>
</div>
</body>
</html>